﻿using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;

using Microsoft.WindowsMobile.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
using System.IO;
using System.Xml.Serialization;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Socket_PDA通信
{
    public partial class Sever : Form
    {

        PdaClient pda;
        public Sever()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pda = new PdaClient();
            pda.ipAdress = textBox1.Text;
            pda.port = Convert.ToInt32(textBox2.Text);
            pda.connect();
            pda.OnMessageCome += new PdaClient.MessageCome(MsgCome);
        }

        private void MsgCome(string a)
        {

            txtsend.Invoke(new ThreadStart(delegate
                {
                    txtsend.Text = txtsend + "\r\n" + a;
                }
            ));

        }

        private void sms_sendbtn_Click(object sender, EventArgs e)
        {
            pda.Send("%R1Q,9028:1,0,0\r\n");
        }


    }

}